﻿
function cAlert(data) {
    jAlert(data, "School Party");
}
function Error() {jAlert("当前网络环境不稳定,请稍后重试", "School Party");}

    function AddFriend(e) {
        var postdata = $(e).attr('data');

        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/AddFriend",
            data: { friendId: postdata },
            success: function (data) {
                cAlert(data);
            },
            error: function () {
                Error();
            }

        });
    }



    function ConfirmFeedBack(e) {

        var postdata = $(e).attr('data');
        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/ConfirmFeedBack",
            data: { requestId: postdata },
            success: function (data) {
                cAlert(data);
            },
            error: function () {
                Error();
            }

        });
    }


    function DeleteFriend(e) {

        var postdata = $(e).attr('data');
        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/DeleteFriend",
            data: { friendId: postdata },
            success: function (data) {
                cAlert(data);
            },
            error: function () {
                Error();
            }

        });


    } //delete friend


    function AcceptFriend(e) {

        var postdata = $(e).attr('data');
        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/AcceptRequestFriend",
            data: { requestId: postdata },
            success: function (data) { cAlert(data) },
            errro: function () { Error(); }
        });

    }

    //accept friend

    function RejectFriend(e) {

        var postdata = $(e).attr('data');
        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/RejectRequestFriend",
            data: { requestId: postdata },
            success: function (data) { cAlert(data); },
            errro: function () { Error(); }
        });

    }

    //reject friend

    function AddFocus(e) {

        var postdata = $(e).attr('data');

        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/AddFocus",
            data: { focusId: postdata },
            success: function (data) {
                cAlert(data);
            },
            error: function () {
                Error();
            }

        });
    }

    function DeleteFocus(e) {

        var postdata = $(e).attr('data');

        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/DeleteFocus",
            data: { focusId: postdata },
            success: function (data) {
                cAlert(data);
            },
            error: function () {
                Error();
            }

        });


    }





   


    function AcceptOpenLover(e) {

        var postdata = $(e).attr('data');

        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/AcceptRequestLover",
            data: { requestId: postdata, open: true },
            success: function (data) {
                cAlert(data);
            },
            error: function () {
                Error();
            }

        });

    }



    function AcceptSecretLover(e) {

        var postdata = $(e).attr('data');

        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/AcceptRequestLover",
            data: { requestId: postdata, open: false },
            success: function (data) {
                cAlert(data);
            },
            error: function () {
                Error();
            }

        });

    }


    function RejectLover(e) {

        var postdata = $(e).attr('data');

        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/RejectRequestLover",
            data: { requestId: postdata },
            success: function (data) {
                cAlert(data);
            },
            error: function () {
                Error();
            }

        });

    }


    function CloseLover() {

        $.ajax({
            type: 'POST',
            url: "http://" + window.location.host + "/Relation/CloseLoverRelation",

            success: function (data) {
                cAlert(data);
            },
            error: function () {
                Error();
            }

        });
   

    }




    function FriendAlbum(e) {

        var postdata = $(e).attr('data');
       
        $.ajax({
            url: '/Album/AllPhotoJson',
            data: { friendId: postdata },
            success: function (data) {
                if (data.length > 0) {
                    $.fancybox(data,
					{
					    'padding': 0,
					    'transitionIn': 'elastic',
					    'transitionOut': 'elastic',
					    'type': 'image',
					    'opacity': true,
					    'changeFade': 0,
					    'overlayColor': '#000', //这是背景颜色
					    'overlayOpacity': 0.9//这是背景透明度
					});
                }
                else cAlert('该用户暂无公开相册!');
            } //end of success

        });  //end ajax


    } //END
    function PublicAlbum(e) {

        var postdata = $(e).attr('data');

        $.ajax({
            url: '/Album/AllPhotoJson',
            data: { friendId: postdata },
            success: function (data) {
                if (data.length > 0) {
                    $.fancybox(data,
					{
					    'padding': 0,
					    'transitionIn': 'elastic',
					    'transitionOut': 'elastic',
					    'type': 'image',
					    'opacity': true,
					    'changeFade': 0,
					    'overlayColor': '#000', //这是背景颜色
					    'overlayOpacity': 0.9//这是背景透明度
					});
                }
                else cAlert('该用户暂无公开相册!');
            } //end of success

        });  //end ajax



    } //end

    function AlbumPhoto(e) {
        var begin = $(e).attr('data').indexOf('albumId=') + "albumId=".length;
        var postdata = $(e).attr('data').substring(begin);
       
        $.ajax({
            url: '/Album/AlbumPhotoJson',
            data: { albumId: postdata },
            success: function (data) {
                if (data.length > 0) {
                    $.fancybox(data,
					{
					    'padding': 0,
					    'transitionIn': 'elastic',
					    'transitionOut': 'elastic',
					    'type': 'image',
					    'opacity': true,
					    'changeFade': 0,
					    'overlayColor': '#000', //这是背景颜色
					    'overlayOpacity': 0.9//这是背景透明度
					});
                }
                else cAlert('你无权访问主人相册!');
            }
        });
    }

    function BigPhoto(e) {
        var src = $(e).attr('src');
        var begin = src.indexOf('image=') + "image=".length;
        var end = src.indexOf('&');
        var str = src.substring(begin, end);
       
        data = [href = str, title = ''];
        $.fancybox(data,
					{
					    'padding': 0,
					    'transitionIn': 'elastic',
					    'transitionOut': 'elastic',
					    'type': 'image',
					    'opacity': true,
					    'changeFade': 0,
					    'overlayColor': '#000', //这是背景颜色
					    'overlayOpacity': 0.9//这是背景透明度
					});

    }



    function AddComment(target, type, comment) {
        $.ajax({
            url: '/FriendTrend/Comment',
            data: { id: target, type: type, comment: comment },
            success: function (data) {
                cAlert(data);
            },
            error:Error()

        });
    }